How to make my code close all active trades on the last trading day on a daily chart for backtesting. I'm too new to this can't figure out how to make it work yet. There were a couple other similar threads but it seemed to me they were about intraday charts which got me really confused.
Size:
Color:
CODE:
Please log in to see this code.
Size:
Color:
Maybe this (inside the normal trading loop)...
CODE:
Please log in to see this code.
I used "- 2" thinking GZTRADE wanted all trades closed out at the end of the backtest
Size:
Color:
Thanks a lot got it working perfectly
Size:
Color:
Eugene
I did something like that but I still see these position in my account tab (paper account 1). what did I do wrong ? I printed out
PrintDebug(IsLastPositionActive) and they are always false but my paperaccount1 shows I have trades there.
CODE:
Please log in to see this code.
Size:
Color:
Have you tried suggestion by LenMoz in post #3?
Size:
Color:
yeah that's what I did... Let me try again this weekend
Size:
Color:
I have attached how my paperaccount1 look like... should that post back in #3 work?
Size:
Color:
It depends on your (unknown) exit order bar. Note that the market is currently closed.
Size:
Color:
still showing the position... when I check to see if position is active is showing false all the time.. It just came to me.. does it matter if I entered the trade using 30 mins, 5 mins or daily data ? I can't remember what I did
Size:
Color:
Did you actually exit that Position with an order? I think you didn't. Either Auto Trading must be enabled for Paper accounts or you right click on an order and click "Place selected order". Then the Accounts tool would reflect the closing of the position.
Size:
Color:
oh , good hint..let me check that tomorrow
Size:
Color:
hmm I don't see orders generated either... what else should I check. activeposition is always false.
Size:
Color:
Size:
Color:
I figured that I can just delete my papertradingaccount and add it back on again!!! problem solved.
Size:
Color: