Syntax Help Needed
Results 1 to 8 of 8

Thread: Syntax Help Needed

  1. #1
    Why does the else give an unexpected error to me?

    It ought to really be if Ask gt; MA_Line perform the collection of top checks to start an order
    else
    perform the collection of bottom checks to start an order... do not understand what's wrong with this syntax

    Thank you for your help!


    Inserted Code void OpenMarketOrders() double MA_Line=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 0,0); double S_Line1=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 1,0); double S_Line2=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 2,0); double S_Line3=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 3,0); double S_Line4=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 4,0); double U_StopLoss=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0,5,0); double L_StopLoss=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0,5,0); double B_Line1=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 1,0); double B_Line2=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 2,0); double B_Line3=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 3,0); double B_Line4=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 4,0); double StochBuyLine = iStochastic(Symbol(),0,14,3,3,1,1,0,0); double StochSellLine = iStochastic(Symbol(),0,14,3,3,1,1,1,0); int line1trades=0, line2trades=0, line3trades=0, line4trades=0; int ticket; if (Tradeable==true) if (Ask lt; MA_Line) (Open#91;0#93; gt; B_Line3 Close#91;0#93; lt;= B_Line3))) ticket = OrderSend(Symbol(),OP_BUY,LotSize*3, Ask, 3, 0, 0, Coach Line3Buy,MagicNumber,0,Green); line3trades = 1; if (line2tradeslt;1 StochBuyLinegt;=StochSellLine StochBuyLinelt;=10 ( (Open#91;0#93; lt; B_Line2 Close#91;0#93; gt;= B_Line2) else (Open#91;0#93; gt; S_Line4 Close#91;0#93; lt;= S_Line4))) ticket = OrderSend(Symbol(),OP_SELL,LotSize*6, Bid, 3, 0, 0, Coach Line4Sell,MagicNumber,0,Red); line4trades = 1; if (line3tradeslt;1 StochSellLinegt;=StochBuyLine StochSellLinegt;=90 ( (Open#91;0#93; lt; S_Line3 Close#91;0#93; gt;= S_Line3)

  2. #2
    Ok, I made some further modifiions.... Please help me clean this up so that it includes best practices...

    * need to pass variables to the CloseOrders function from OpenOrders function
    * label if or not a ticket is a buy or sell
    * everything things to add so that an EA knows to monitor transactions if for some reason it's MBT is restarted?
    *any other recommendation to make sure there isn't a hole someplace
    *the best way to take care of trading would be to have a continual loop assessing whether to start or close orders in the start function, right?
    *the Reply to these questions Will Probably help in moving a long way to understanding the concepts of Metatrader Programming/Trading

    Inserted Code void CloseMarketOrders() if ClosingBuys if ClosingSells line1tradesgt;0 OrderClose(ticket); if (ticket = line4ticket) line4trades=0; if (ticket = line3ticket) line3trades=0; if (ticket = line2ticket) line2trades=0; if (ticket = line1ticket) line1trades=0; double LotSize() double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100; return (lotMM); void OpenMarketOrders() { double MA_Line=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 0,0); double S_Line1=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 1,0); double S_Line2=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 2,0); double S_Line3=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 3,0); double S_Line4=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 4,0); double U_StopLoss=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0,5,0); double L_StopLoss=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0,5,0); double B_Line1=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 1,0); double B_Line2=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 2,0); double B_Line3=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 3,0); double B_Line4=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 4,0); double StochBuyLine = iStochastic(Symbol(),0,14,3,3,1,1,0,0); double StochSellLine = iStochastic(Symbol(),0,14,3,3,1,1,1,0); int line1trades=0, line2trades=0, line3trades=0, line4trades=0; int ticket; double LotSize = LotSize(); bool Tradeable = true; if (LotSize()lt;0.01*xecn) LotSize=0.01*xecn; if (LotSize()gt;100) LotSize=100; if (Tradeable==true) if (Ask lt; MA_Line) (Open#91;0#93; gt; B_Line2 Close#91;0#93; lt;= B_Line2))) ticket = OrderSend(Symbol(),OP_BUY,LotSize*2, Ask, 3, 0, 0, Coach Line2Buy,MagicNumber,0,Green); line2trades = 1; line2ticket = ticket; if (line1tradeslt;1 StochBuyLinegt;=StochSellLine StochBuyLinelt;=12 ((Open#91;0#93; lt; B_Line1 Close#91;0#93; gt;= B_Line1) else

  3. #3
    Too curled brackets.

    Inserted Code void OpenMarketOrders() double MA_Line=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 0,0); double S_Line1=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 1,0); double S_Line2=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 2,0); double S_Line3=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 3,0); double S_Line4=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0, 4,0); double U_StopLoss=iCustom(NULL,0,MA StdDev,MA_Period, 1, 6, 0,5,0); double L_StopLoss=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0,5,0); double B_Line1=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 1,0); double B_Line2=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 2,0); double B_Line3=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 3,0); double B_Line4=iCustom(NULL,0,MA-StdDev,MA_Period, 1, 6, 0, 4,0); double StochBuyLine = iStochastic(Symbol(),0,14,3,3,1,1,0,0); double StochSellLine = iStochastic(Symbol(),0,14,3,3,1,1,1,0); int line1trades=0, line2trades=0, line3trades=0, line4trades=0; int ticket; if (Tradeable==true) if (Ask lt; MA_Line) (Open#91;0#93; gt; B_Line1 Close#91;0#93; lt;= B_Line1))) ticket = OrderSend(Symbol(),OP_BUY,LotSize, Ask, 3, 0, 0, Coach Line1Buy,MagicNumber,0,Green); line1trades = 1; else if (line4tradeslt;1 StochSellLinegt;=StochBuyLine StochSellLinegt;=90 ( (Open#91;0#93; lt; S_Line4 Close#91;0#93; gt;= S_Line4)

  4. #4
    Ok, using this function above, I want to pass variables into this function.... What's the best way?

    Also, what is the ideal way logically to understand what line is being shut so I can change it back to 0?

    Where could I put the error handling in each? Once I get the near and error handling, I think my EA should Have the Ability to work since I really don't have any modify

    Inserted Code void CloseMarketOrders() if ClosingBuys if ClosingSells if (StochSelLine lt; 50 StochBuyLinegt;=StochBuyLine Bid lt; S_Line1 OrderSymbol()=Symbol() OrderMagicNumber()=MagicNumber) while line4tradesgt;0

  5. #5
    Actually, I need to also incorporate the StopLoss line near, but that ought to be easy once I get a grasp of the overall concept.... Thanks

  6. #6
    Is that the code that is complete? Where's the beginning function?

  7. #7
    Ok this is the complete code

    it's very close and I am convinced within ten minutes you will be able to provide best practices information and allow me to resolve the previous handful of items

    * I have two errors which are the same since it isn't recognizing the ticket variable to close the order
    * do I require a constant loop in the beginning section as it's only assessing two purposes?
    * where should I include error handling?
    * what occurs when MetaTrader is restarted? What do I want to do for it know what trades are lines that are in and available what?

    DecisionI will come up exactly what I will do using the tradeable function (i.e., don't trade on Fridays, but manage trades still open on Friday... and not to trade if not enough capital)
    *I shall add in hidden tp and sl
    https://www.forexforum.co.za/attachm...1230407706.mq4

  8. #8
    I think I fixed the ticket difficulty.... Can somebody please offer input on another things that are remaining and check that?

    It ought to be significantly less than 10 minutes for somebody with expertise to notate the required changes.... This one is compiling without any errors so that it ought to be a lot easier to deal with now
    https://www.forexforum.co.za/attachm...1425372810.mq4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.