Backtest: How to enter a trade at the Open of the *next* bar
Created at 07 Nov 2024, 13:09
MA
Backtest: How to enter a trade at the Open of the *next* bar
07 Nov 2024, 13:09
Hi,
There could someone explain to me how to execute a trade based on the Open Price of the next bar once the Closing Price of the latest bar has been generated and the bar is complete?
Essentially, I am looking for something like an “OnBarOpen” method or similar.
Thanks
Replies
markmath01
09 Nov 2024, 18:01
( Updated at: 10 Nov 2024, 15:35 )
RE: Backtest: How to enter a trade at the Open of the *next* bar
firemyst said:
If you're programming a bot, use the OnBar() method.
using System;using System.Collections.Generic;using System.Linq;using System.Text;using cAlgo.API;using cAlgo.API.Collections;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo{ [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class ThirdBarMarketOrderBot : Robot { private int barCount; protected override void OnStart() { barCount = 0; } protected override void OnBar() { barCount++; Print ("Bar count {0}", barCount); } }}
You can find more about it by googling “calgo onbar”
Thanks !
@markmath01
firemyst
09 Nov 2024, 13:50
If you're programming a bot, use the OnBar() method.
You can find more about it by googling “calgo onbar”
@firemyst