Hello everyone, I am having some trouble trying to edit the code for the DMI Oscillator strategy on think or swim. I am trying to add a long signal on the hist every time the value crosses 22.5 and a short every time crosses -22.5 but this is a bit trickier then I thought. I've gotten s far as to write out the basic code for these commands but I think it's not working because I am using a constant with an "if" expression the wrong way. Because apparently this isn't the correct way. Can anybody help me get this right?
plot <Hist>;
if <integer crosses 22.5> [then] {
<Hist> = <OrderType.BUY_TO_OPEN>;
} else {
if <integer crosses -5> [then] {
<Hist> = <SELL_TO_CLOSE>;
} else {
<plot_name> = <expression3>;
}
}
plot <Hist>;
if <integer crosses 22.5> [then] {
<Hist> = <OrderType.SELL_TO_OPEN>;
} else {
if <integer crosses 10> [then] {
<Hist> = <BUY_TO_CLOSE>;
} else {
<plot_name> = <expression3>;
}
}
plot <Hist>;
if <integer crosses 22.5> [then] {
<Hist> = <OrderType.BUY_TO_OPEN>;
} else {
if <integer crosses -5> [then] {
<Hist> = <SELL_TO_CLOSE>;
} else {
<plot_name> = <expression3>;
}
}
plot <Hist>;
if <integer crosses 22.5> [then] {
<Hist> = <OrderType.SELL_TO_OPEN>;
} else {
if <integer crosses 10> [then] {
<Hist> = <BUY_TO_CLOSE>;
} else {
<plot_name> = <expression3>;
}
}
Last edited by a moderator: