Does Bars.ClosePrices give me the actual close price of a bar ?
20 Feb 2024, 10:36
I am not understanding what sort of info I get from Bars.OpenPrices/Bars.ClosePrices. I have coded this logic so that it looks for a certain pattern and the logic isn't doing what I want it to do.
You can see here although in the code the close of bar 2 should be greater than or equal to the open of bar 3 but in this pic its tell yet the Bot still took the trade .
In case you wondering what the rest code is like : // parent method to check rules and open bullish trade or send signal. private void TradeRulesBullish() { // flag to open a trade if all rules true. bool OpenBuyTrade = false;
if (IsBullishSignal() && !IsBullishPullBack() ) { OpenBuyTrade = true; }
if (OpenBuyTrade) { if (!IsBullish) { if (!IsTradeOpen(TradeType.Buy)) {
I don't understand what you're saying. Read that sentence outloud to yourself, especially the italics part:
“You can see here although in the code the close of bar 2 should be greater than or equal to the open of bar 3 but in this pic its tell yet the Bot still took the trade .”
In the screen capture you provided, the close of 2 bars back is greater than the close of the 3rd bar back from the current bar.
I don't understand what you're saying. Read that sentence outloud to yourself, especially the italics part:
“You can see here although in the code the close of bar 2 should be greater than or equal to the open of bar 3 but in this pic its tell yet the Bot still took the trade .”
In the screen capture you provided, the close of 2 bars back is greater than the close of the 3rd bar back from the current bar.
Not the close price the open price , the close of 2 bars back should be greater or equal to the open of the third bar back. Its in the code : if (
As far as I can see, the trade was taken three bars ago. Therefore these are the bars you should be looking at
I have been changing the code and testing it in the back tester and as far as I can tell for some reason the trades are entered late after the pattern has appeared and I'm not understanding why . Even just using this code : // returns true if bullish pullback private bool IsBullishPullBack() {
As far as I can see, the trade was taken three bars ago. Therefore these are the bars you should be looking at
I have been changing the code and testing it in the back tester and as far as I can tell for some reason the trades are entered late after the pattern has appeared and I'm not understanding why . Even just using this code : // returns true if bullish pullback private bool IsBullishPullBack() {
} And nothing else when looking to open trades it still enters the trades late
Here is an example on the live market , why did it take this trade ? I don't understand cause the pattern isn't there . Whats going on ? This order was made on 8:15 so I know that the pattern isn't there during that time and that its not possible for it to be an old oder.
I still do not understand what the problem is. The cBot does exactly what you have programmed it to do. Here are the bars you are checking. The Open price is higher than the previous close price.
As far as I can see, the trade was taken three bars ago. Therefore these are the bars you should be looking at
I have been changing the code and testing it in the back tester and as far as I can tell for some reason the trades are entered late after the pattern has appeared and I'm not understanding why . Even just using this code : // returns true if bullish pullback private bool IsBullishPullBack() {
} And nothing else when looking to open trades it still enters the trades late
Here is an example on the live market , why did it take this trade ? I don't understand cause the pattern isn't there . Whats going on ? This order was made on 8:15 so I know that the pattern isn't there during that time and that its not possible for it to be an old oder.
Hello, hopefully I can help a little bit.
Delete: AOpen2 > ALow3. <---- because this factor is already confirmed with: AClose3 < AOpen2 (I found it easier to follow the flow as: AOpen2 > AClose3).
Changed: AClose2 >= AOpen3 <---- Why not just make it AClose2 >= AOpen2, because: AOpen2 > AClose3 ensures the intended outcome.
(AClose3 < AClose4) && /// Bearish candle
AOpen2 > AClose3 && AClose2 >= AOpen2 && /// Bullish/spinner candle with gap
arnyfesto1
21 Feb 2025, 09:12
( Updated at: 28 Feb 2025, 09:12 )
Note: Order's stoploss and takeprofit are only in Pips.
if you want Bars.ClosePrices.Last(3) as StopLoss you need to enter a trade without SL and TP, Then calculate (Position.EntryPrice - Bars.ClosePrices.Last(3)) / Symbol.PipSize and ModifyPosition(position.Buy, SL, TP, ProtectionType.Relative)
arnyfesto1
21 Feb 2025, 09:12
( Updated at: 28 Feb 2025, 09:12 )
Note: Order's stoploss and takeprofit are only in Pips.
if you want Bars.ClosePrices.Last(3) as StopLoss you need to enter a trade without SL and TP, Then calculate (Position.EntryPrice - Bars.ClosePrices.Last(3)) / Symbol.PipSize and ModifyPosition(position.Buy, SL, TP, ProtectionType.Relative)
firemyst
21 Feb 2024, 01:25
I don't understand what you're saying. Read that sentence outloud to yourself, especially the italics part:
“You can see here although in the code the close of bar 2 should be greater than or equal to the open of bar 3 but in this pic its tell yet the Bot still took the trade .”
In the screen capture you provided, the close of 2 bars back is greater than the close of the 3rd bar back from the current bar.
@firemyst