Generating Magic Number for Cross Close EA

 

Looking for someone to edit this existing MA Cross EA that automatically closes positions when price touches the pre-determined MA.

Currently it will only close positions accurately when they are generated by an existing EA rather than when manually placed so I need someone to add a Magic Number generator for the Cross EA so that it knows which positions to close.

Thanks in advance. 

Files:
 
Matthew Lane: Currently it will only close positions accurately when they are generated by an existing EA rather than when manually placed so I need someone to add a Magic Number generator for the Cross EA so that it knows which positions to close.

Wrong. There are no magic number tests in the code. It closes any order on the current chart. Manual or EA is irrelevant.

 
It just seems to close any open trade if i'm honest, do you know any way to make it work for me?
 
Matthew Lane: It just seems to close any open trade if i'm honest, do you know any way to make it work for me?
  1. What part of "closes on the current chart" was unclear? It doesn't "close any open trade."
  2. What doesn't work for you?

  3. Close Mode controls where market is vs MA
       Stealth = 0, // Stealth: Bid <= MA or Ask >=MA
       Spread = 1   // Spread: Bid < MA and Ask > MA
    

    The default is Stealth (0) so it will close the buy order if the Bid is below MA and sell order when Ask is above MA. As opposed to crossing MA.

  4. Only bug I see, the sign wrong for buyss when using Points_to_cross (default=0.)

    Buy orders
    Bid <= ma - Points_to_cross
    solid cross
    Sell orders
    Ask >= ma - Points_to_cross
    premature close
    Fixed and attached
Files:
 
William Roeder:
  1. What part of "closes on the current chart" was unclear? It doesn't "close any open trade."
  2. What doesn't work for you?

yeah ok my wording was unhelpful there, I understand what you mean by closes on the current chart.

What seems to happen is that whenever a new trade is opened on the chart that the EA is running on it is immediately closed despite it not being near the MA selected in the settings; i.e price isn't crossing the MA.

I suggested you try it on a demo and then you'll understand what I mean hopefully. Thanks

 
William Roeder:
  1. What part of "closes on the current chart" was unclear? It doesn't "close any open trade."
  2. What doesn't work for you?

  3. Close Mode controls where market is vs MA

    The default is Stealth (0) so it will close the buy order when Bid goes below MA and sell order when Ask goes above MA.

  4. Only bug I see, the sign wrong for sells when using Points_to_cross (default=0.)

    Buy orders
    solid cross
    Sell orders
    premature close
    Fixed and attached

Will try this second version out, thank you

 
Matthew Lane: immediately closed despite it not being near the MA selected in the settings; i.e price isn't crossing the MA.

What part of #3.3 was unclear? That is exactly what is should do with the default setting of Close Mode = Stealth.

 


William Roeder:

  1. What part of "closes on the current chart" was unclear? It doesn't "close any open trade."
  2. What doesn't work for you?

  3. Close Mode controls where market is vs MA

    The default is Stealth (0) so it will close the buy order if the Bid is below MA and sell order when Ask is above MA. As opposed to crossing MA.

  4. Only bug I see, the sign wrong for buyss when using Points_to_cross (default=0.)

    Buy orders
    solid cross
    Sell orders
    premature close
    Fixed and attached

works perfectly, think it was the sell order problem that made it close straight away and hence caused the misunderstanding.


Thanks William appreciate the effort!

Reason: