I have some trouble managing alerts:
I am trying to set a strategy in a way that every operation (Buy/Sell) it does on chart is accompained not just with the audio alert, but also with the yellow visual alert (That I need to remain "always open" until I check on the operation).
Coding with PowerLanguage I am able to generate the proper alert with operations such as "next bar market" but I have trouble whenever some Entries/Exits happened by stop/limit intrabar, as I cannot make a proper contition to control such alert.
As well, I am not able to set an alert for a stop loss exit derived by "SetStopContract" "SetStopLoss()".
My ideal situation, as I am working with many Workspace, would be to have a visual alert for each operation regardless the nature: if the chart plots it, i would need the alert. And, just to ask something more, I'd love to have the possibility to manage also the colour of such visual alert.
Again, the ideal situation should be that a feature like that would be provided externally of the code.
Any suggestion or comments?
Visual Alert every Entry/Exit of whatsoever signal
-
- Posts: 5
- Joined: 16 Feb 2015
- Has thanked: 2 times
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Visual Alert every Entry/Exit of whatsoever signal
You could for example keep track of how many open contracts there are currently compared to the previous calculation of the strategy. That way you could determine whether a position was opened, increased, or decreased. Purely an example to get you started:I am trying to set a strategy in a way that every operation (Buy/Sell) it does on chart is accompained not just with the audio alert, but also with the yellow visual alert (That I need to remain "always open" until I check on the operation).
Coding with PowerLanguage I am able to generate the proper alert with operations such as "next bar market" but I have trouble whenever some Entries/Exits happened by stop/limit intrabar, as I cannot make a proper contition to control such alert.
As well, I am not able to set an alert for a stop loss exit derived by "SetStopContract" "SetStopLoss()".
Code: Select all
Variables:
IntraBarPersist PrevMP(0),
MP(0);
MP = MarketPosition(0) * CurrentContracts;
if (MP > 0 and PrevMP = 0) then
// Long position opened
else if (MP < 0 and PrevMP = 0) then
// Short position opened
else if (MP > PrevMP and PrevMP > 0) then
// Added to long position
else if (MP < PrevMP and PrevMP < 0) then
// Added to short position
else if (MP > PrevMP and PrevMP < 0) then
// Reduced short position
else if (MP < PrevMP and PrevMP > 0) then
// Reduced long position
PrevMP = MP;
Such type of exits can be tracked in the code with the PostTradeExitName() keyword and/or (depending on the other exit orders in your strategy) with the PosTradeExitCategory() keyword.As well, I am not able to set an alert for a stop loss exit derived by "SetStopContract" "SetStopLoss()".
-
- Posts: 5
- Joined: 16 Feb 2015
- Has thanked: 2 times
Re: Visual Alert every Entry/Exit of whatsoever signal
Thanks Josh, I was indeed able to track my operations in this way.
I just note that I implemented that strategy with RecalcLastBarAfter(1), so that the alert pops up the tick imediately following any operation, instead waiting next end of bar. In this way I can track also the exit from "SetStopLoss".
For this reason we decided also to keep this few line of code in a separated strategy. I now have to apply it to all my strategies, and I am trying to understand if this will burden my CPU usage.
I'll open anyway a feature request.
I just note that I implemented that strategy with RecalcLastBarAfter(1), so that the alert pops up the tick imediately following any operation, instead waiting next end of bar. In this way I can track also the exit from "SetStopLoss".
For this reason we decided also to keep this few line of code in a separated strategy. I now have to apply it to all my strategies, and I am trying to understand if this will burden my CPU usage.
I'll open anyway a feature request.