what Wrong in this script

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

#include <stdlib.mqh>
#include <WinUser32.mqh>
extern double Lots = 0.01;
extern bool   UseMoneyMgmt = true;
extern double RiskPercent = 1;
extern double Entry = 0.0000;

int start()
  {
   double Risk = RiskPercent / 100;
   if (UseMoneyMgmt)
   Lots = NormalizeDouble( AccountBalance()*0.0001/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);
   int Mode = OP_BUYSTOP;
   if (Ask > Entry && Entry > 0) Mode = OP_BUYLIMIT;
   if (Entry == 0) {Entry = Ask; Mode = OP_BUY;}
   int ticket=OrderSend(Symbol(),Mode,Lots,Bid+1*Point,1,0,Bid+100*Point,Mode,255,TimeCurrent()+7300,CLR_NONE);
   if(ticket<1)
     {
      int error=GetLastError();
      Print("Error = ",ErrorDescription(error));
      return(0);
     }
//----
   OrderPrint();
   return(0);
  }

//+------------------------------------------------------------------+

 no error when compile it. but i test it on data from 1-5-2016 to 30-5-2016 with amount 100$ is gives profit 554$ but it down to 77$ i will upload the out of the output i'm using MT4 for fxpro

Thanks

 

 1

 
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Your risk calculation is bogus
    • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerlot + CommissionPerLot) (Note OOP-OSL includes the SPREAD)
    • Do NOT use TickValue by itself - DeltaPerlot
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out
 

thanks WHRoeder for your concern . i'm not good in coding but i can read the code and make changes on it as i need .so could you give me more detail to understand .

can you tech me how to solve this issues ?

thanks

 
#include <stdlib.mqh>
#include <WinUser32.mqh>

int start()
  {
//----

//----
int ticket=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+30*Point,1,0,Bid+50*Point,"Buy ",255,TimeCurrent()+7200,CLR_NONE);
if(ticket<1)
     {
      int error=GetLastError();
      return(0);
     }
//----
   OrderPrint();
   
   return(0);
  }

//

1 

if i run this code without any other codes like risk or money management it gives me this  out .tech me how to solve this issue 

thanks

 

 
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. int ticket=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+30*Point,1,0,Bid+50*Point,"Buy ",255,TimeCurrent()+7200,CLR_NONE);
    No stop loss. All open orders became loses.