How to find the time of the bar where the moving averages crossed? (code inside) - page 2

 

Oh and Alladir - you seem the obnoxious type.

 Do yourself a favour and stop wasting your own time writing on this thread or any future ones I may write, if all your going to do is troll and not be helpful in anyway.

 
DomGilberto:

Oh and Alladir - you seem the obnoxious type.

 Do yourself a favour and stop wasting your own time writing on this thread or any future ones I may write, if all your going to do is troll and not be helpful in anyway.

If you can't be civil don't post.
 

WHRoader (if you don't mind) could you tell me if I am right or wrong in this?

double buyPrice = iHighest(Symbol(), 0, MODE_HIGH, iBarShift(Symbol(), 0, triggerBarTime, true), 0); 

int Buy_Price = buyPrice; 

int buyticket = OrderSend(Symbol(),Buy_Price,LotSize,Ask,3,0,0,NULL,MagicNumber,0,Green);   Usually I'd put OP_BUY where Buy_Price is...

 

Are you saying that because iHighest simply states a bar number,  me trying to put Buy_Price where OP_BUY used to be, doesn't make any sense because OrderSend takes a double? (when iHighest is an integer?)

How can I convert my iHighest logic into a price though so that my OrderSend function understands that I am wanting to buy the highest of the iHighest range?

 
RaptorUK:
If you can't be civil don't post.


Yea, you're right. Sorry.
 
DomGilberto:

WHRoader (if you don't mind) could you tell me if I am right or wrong in this?

  "double buyPrice = iHighest(Symbol(), 0, MODE_HIGH, iBarShift(Symbol(), 0, triggerBarTime, true), 0);" 

 int Buy_Price = buyPrice; 

 "int buyticket = OrderSend(Symbol(),Buy_Price,LotSize,Ask,3,0,0,NULL,MagicNumber,0,Green);"   Usually I'd put OP_BUY where Buy_Price is...


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

  2. "double buyPrice = iHighest... 
    "double price = int bar index," makes no sense. Break it down:
    // double buyPrice = iHighest(Symbol(), 0, MODE_HIGH, iBarShift(Symbol(), 0, triggerBarTime, true), 0);
    int    iTBT     = iBarShift(Symbol(), 0, triggerBarTime, true),
           iHH      = iHighest(Symbol(), 0, MODE_HIGH, iTBT + 1, 0); // Include tBT bar. Len = from - to + 1
    double buyPrice = High[iHH];
    
  3. If most of the functions (except marketInfo) you don't need to use Symbol(). You can use NULL as current chart symbol, just as you already use 0 as current chart timeframe.
 

Omg - Why is it so clear after you realise! I guess this is where practice makes perfect. 

I honestly get it much better now. Put a :) on my face!

I'm going to try and get this done now and see what I can come out with!

 

Thank you!! 

 
int buyticket = OrderSend(Symbol(),buyPrice,LotSize,Ask,3,0,0,NULL,MagicNumber,0,Green);

When I attempt to use this below, I am getting an error in the journal saying that OrderSend cmd function must be an integer?

I'm obviously not understanding because you've mentioned that "OrderSend only takes a price (a double) it makes no sense to open an order at 9"

Obviously if I change it to "int Buy_Price = buyPrice" this works to place the orders, but it isnt relevant to where the entry should be. (This is my last question - I don't want to take the mick of course!)  

int iTBT= iBarShift(NULL,60, triggerBarTime, true),
         iHH= iHighest(NULL,60, MODE_HIGH, iTBT + 1, 0); // Include tBT bar. Len = from - to + 1
            double buyPrice = High[iHH];
 
DomGilberto:

When I attempt to use this below, I am getting an error in the journal saying that OrderSend cmd function must be an integer?

I'm obviously not understanding because you've mentioned that "OrderSend only takes a price (a double) it makes no sense to open an order at 9"

Obviously if I change it to "int Buy_Price = buyPrice" this works to place the orders, but it isnt relevant to where the entry should be. (This is my last question - I don't want to take the mick of course!)  

The error is the   cmd  in the OrderSend(),  I know you don't want to hear it but if you want to learn you must also learn to check the documentation and learn how to read it . . .  it is all part of the process . . .  when I code an OrderSend() command I check it against the documentation every time to check I have remembered correctly.

int buyticket = OrderSend(Symbol(),buyPrice,LotSize,Ask,3,0,0,NULL,MagicNumber,0,Green);

What type of Order is this ?  click -->  OrderSend()   says the 2nd parameter is    cmd  -   Operation type. It can be any of the Trade operation enumeration.

 

Yea you're right RaptorUK - I do actually (pretty much on everything I do) is read the documentation (finger is practically sitting on F1 all the time.)

Jesus - With fresh eye's I've realised how stupid I've been!

I didn't mean to put buyPrice at the cmd - second parameter, I meant to place that at the 4th parameter (double Price)! 

So that works (putting it in the right order) - I have changed it to a buy and sellstop orders. God i'm annoyed at how moronic I've been!

 

int buyticket = OrderSend(Symbol(),OP_BUYSTOP,LotSize,buyPrice,3,bsl,btp,NULL,MagicNumber,0,Green); 
      if(buyticket>0)OrderModify(buyticket,OrderOpenPrice(),bsl,btp,0,CLR_NONE);

int iTBT= iBarShift(NULL,60, triggerBarTime, true),
        iHH= iHighest(NULL,60, MODE_HIGH, iTBT + 1, 0); // Include tBT bar. Len = from - to + 1
            double buyPrice = High[iHH];

 The "buyPrice" is simply slapping the Order above the high of the most recent closed bar that touched the 21 EMA (instead of the bar that was the highest of the MA cross and the bar that touched the 21 EMA...)

I'll have a play around and see where I am going wrong! (spent so much time staring at this its becoming painful now lol.)

 

Thank you!!!! 

 

 

(p.s what does  // Include tBT bar. Len = from - to + 1 note mean?)

 
  1. DomGilberto:

    (p.s what does  // Include tBT bar. Len = from - to + 1 note mean?)

    HH= iHighest(NULL,60, MODE_HIGH, iTBT + 1, 0); // Include tBT bar. Len = from - to + 1

    Highest bar index starting at zero for iTBT+1 bars includes the iTBT bar.

    Your original post

    double buyPrice = iHighest(Symbol(), 0, MODE_HIGH, iBarShift(Symbol(), 0, triggerBarTime, true), 0);
    
    did not include the triggerBarTime bar.
  2. iHH= iHighest(NULL,60, MODE_HIGH, iTBT + 1, 0); // Include tBT bar. Len = from - to + 1
    double buyPrice = High[iHH];
    Why did you change the NULL,0 to NULL,60? Now iHH is only valid for the PERIOD_H1 chart, and if the current chart is NOT the H1, then High[iHH] is bogus.
Reason: