Skip navigation.
Home
Metatrader community - Forex Trading with Metatrader

Greetings, looking for some code

Metatrader 4

Hello,

I am looking for code that will let this script put on a trade; my understanding is that I need to account
For maximum, minimum and market info mode step in order for it to function correctly.

I am a learning coder, and any help is greatly appreciated, also thank you Coders Guru for this website which will help me learn to code.

Best regards Dale.

The Idea of the script is to use high [1] - low [1] to calculate lots, the account percentage risk is fixed at 1/4 percent.

//+------------------------------------------------------------------+
//| send_pending.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property show_confirm

//+------------------------------------------------------------------+
//| script "send pending order with expiration data" |
//+------------------------------------------------------------------+
int start()
{
int ticket,expiration;
double point;
double sprd;
//----
point=MarketInfo(Symbol(),MODE_POINT);
expiration=CurTime()+PERIOD_D1*60;

double PercentToRisk =.25; //Risk is set a 1/4 percent
double Risk = PercentToRisk/100;
// Sprd = //working on spread but getting illegal assignment message

double StopLoss = ( (High[1]+(5*Point)) - (Low[1]-(3*Point) ) ) / Point; //Devide by 100 here for mini
double Lots = NormalizeDouble((AccountBalance()*Risk/StopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE))/100),2);

MessageBox("Lots=" + (Lots));
MessageBox("Executing GBP/USD BUYSTOP");
MessageBox("STOP AT LOW[1]");

while(true)
{
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,(High[1]+5*point),(Low[1]-1),0,"LONG OTTA",16384,expiration,Green);
if(ticket