Is it possible to get a price when a specific study becomes true?

PlusEVTrades

New member
I'm attempting to get a price at the time when my study becomes true. For example, when macd crosses over, can I assign the current "mark" to a variable?

I'd like to use that price for an addorder on a later bar.

I'm not quite sure where to start on code, but lets say for example

:
Code:
def macdsignal = value crosses above signal line;
def entrytargetprice = price when macdsignal is true;

AddOrder(OrderType.BUY_TO_OPEN, price crosses below entrytargetprice,entrytargetprice,
100,tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "BuyOrder100");

Something to that effect seems like the logic I'd be using but I'm not sure if I can obtain price.
 

Pensar

Well-known member
VIP
@PlusEVTrades Maybe try something like def entrytargetprice = if macdsignal then close else entrytargetprice[1];? That may or may not work, but its an idea. If I have it correct, the variable entrytargetprice should hold each value until the next time the value line crosses above the signal line.
 

rad14733

Well-known member
VIP
@PlusEVTrades You can do it with either AddLabel() or AddChartBubble() using the same logic as you would when creating AddOrder()... However, AddLabel() would only display until the next candle that doesn't meet your criteria paints... I'm pretty sure the entry price of AddOrder() can be had using EntryPrice(), but it would be easier to use the price the logic provides...
 

PlusEVTrades

New member
@PlusEVTrades You can do it with either AddLabel() or AddChartBubble() using the same logic as you would when creating AddOrder()... However, AddLabel() would only display until the next candle that doesn't meet your criteria paints... I'm pretty sure the entry price of AddOrder() can be had using EntryPrice(), but it would be easier to use the price the logic provides...
Yeah I basically need the entryprice (), but without the addorder. Is that possible? I want to use that price for a different add order at a later bar.
 

rad14733

Well-known member
VIP
Yeah I basically need the entryprice (), but without the addorder. Is that possible? I want to use that price for a different add order at a later bar.

In that case you would just use the logic that would trigger AddOrder() but use it to paint AddChartBubble() and use the price at the time of the trigger... That should give a more accurate price than the standard of open[+1] (open of next candle after trigger) used in most Strategies... You'd have to play with it...
 

PlusEVTrades

New member
In that case you would just use the logic that would trigger AddOrder() but use it to paint AddChartBubble() and use the price at the time of the trigger... That should give a more accurate price than the standard of open[+1] (open of next candle after trigger) used in most Strategies... You'd have to play with it...
Can I get that price with "mark" or does it have to be something arbitrary like open/close/hl2 ?
 

rad14733

Well-known member
VIP
@PlusEVTrades No, MARK is not available in Studies as a price choice, nor is Bid or Ask which is what MARK is derived from... But during the painting of a bar Close is usually the same as Last, which also is not available in and of itself... So you could use Open, High, Low, Close or HL2...
 

PlusEVTrades

New member
Interesting so addorder creates a entryprice() variable is that the only to get a specific price from a study then? The reason why is I'd like to get the price at the time the study procs, and use it as a buy entry at a later time. But I can't seem to capture that price, even though I know TOS is holding it as a variable in entryprice().
 
Top