function run() { NumYears = 3; BarPeriod = 1; LookBack = 1440; PlotScale = 15; Commission = 0.6; Spread = 0.5*PIP; int Duration = 1, i = 0; if(!is(LOOKBACK)) while(Duration <= 1440) { var Win = abs(priceClose(Duration)-priceClose(0))*PIPCost/PIP; var Cost = Commission*LotAmount/10000. + Spread*PIPCost/PIP; //printf("\nWin %.2f Cost %.2f",Win,Cost); // Breakeven: // Profit = Cost = Rate * Win - (1.-Rate) * Win; // => Cost = (Rate - 0.5) * 2 * Win; var Rate = ifelse(Win>Cost, Cost/(2*Win) + 0.5, 1.); plotBar("Min Rate",i,Duration,100*Rate,AVG+BARS,RED); if(Duration < 10) Duration += 1; else if(Duration < 60) Duration += 5; else if(Duration < 180) Duration += 30; else Duration += 60; i++; } Bar += 100; }
void adjust_parameter_startup() { COLOR *tint = NULL; COLOR *vig = NULL; while(true) { if(uniform) { switch(current_shader) { case CRT: { draw_text(str_printf(NULL, "Intensity = %.2f\nScale = %.2f\nGamma = %.2f\nAlpha = %.2f", (double) ppCrtGetIntensity(uniform), (double) ppCrtGetScale(uniform), (double) ppCrtGetGamma(uniform), (double) ppCrtGetAlpha(uniform)), screen_size.x - 150.0, 15.0, COLOR_WHITE); param1 = ppCrtGetIntensity(uniform); ppCrtSetIntensity(uniform, param1 + (key_t - key_y) * 0.25 * time_step); param2 = ppCrtGetScale(uniform); ppCrtSetScale(uniform, param2 + (key_g - key_h) * 0.25 * time_step); param3 = ppCrtGetGamma(uniform); ppCrtSetGamma(uniform, param3 + (key_u - key_i) * 0.25 * time_step); param4 = ppCrtGetAlpha(uniform); ppCrtSetAlpha(uniform, param4 + (key_j - key_k) * 0.45 * time_step); if(key_b) { while(key_b) wait(1.0); mode++; mode = (mode + 1) % PP_CRT_MODE_CNT; ppCrtSetMode(uniform, mode); } if(key_n) { while(key_n) wait(1.0); mode--; mode = ifelse(mode < 0, PP_CRT_MODE_CNT - 1, mode); ppCrtSetMode(uniform, mode); } break; } case SEPIA: { draw_text(str_printf(NULL, "Alpha = %.2f", (double) ppSepiaGetAlpha(uniform)), screen_size.x - 150.0, 15.0, COLOR_WHITE); param1 = ppSepiaGetAlpha(uniform); ppSepiaSetAlpha(uniform, param1 + (key_j - key_k) * 0.75 * time_step); if (mode == PP_SEPIA_MODE_TINT) { tint = ppSepiaGetTint(uniform); tint->red += (key_t - key_y) * 5 * time_step; tint->green += (key_g - key_h) * 5 * time_step; tint->blue += (key_u - key_i) * 5 * time_step; draw_text(str_printf(NULL, "Custom sepia color (PP_SEPIA_MODE_TINT):\nRed = %d [T]/[Y]\nGreen = %d [G]/[H]\nBlue = %d [U]/[I]", (int)tint->red, (int)tint->green, (int)tint->blue), 50, 300, COLOR_WHITE); ppSepiaSetTint(uniform, tint); } if(key_b) { while(key_b) wait(1.0); mode++; mode = (mode + 1) % PP_SEPIA_MODE_CNT; ppSepiaSetMode(uniform, mode); } if(key_n) { while(key_n) wait(1.0); mode--; mode = ifelse(mode < 0, PP_SEPIA_MODE_CNT - 1, mode); ppSepiaSetMode(uniform, mode); } break; } case GRAYSCALE: { draw_text(str_printf(NULL, "Alpha = %.2f", (double) ppGrayscaleGetAlpha(uniform)), screen_size.x - 150.0, 15.0, COLOR_WHITE); param1 = ppGrayscaleGetAlpha(uniform); ppGrayscaleSetAlpha(uniform, param1 + (key_j - key_k) * 2.5 * time_step); if(key_b) { while(key_b) wait(1.0); mode++; mode = (mode + 1) % PP_GRAYSCALE_MODE_CNT; ppGrayscaleSetMode(uniform, mode); } if(key_n) { while(key_n) wait(1.0); mode--; mode = ifelse(mode < 0, PP_GRAYSCALE_MODE_CNT - 1, mode); ppGrayscaleSetMode(uniform, mode); } break; } case VIGNETTE: { float coverage_start = ppVignetteGetStart(uniform); float coverage_end = ppVignetteGetEnd(uniform); draw_text(str_printf(NULL, "Alpha = %.2f\nCoverage = %.2f", (double) ppVignetteGetAlpha(uniform), (double) coverage_start), screen_size.x - 150.0, 15.0, COLOR_WHITE); param1 = ppVignetteGetAlpha(uniform); param1 += (key_c - key_v) * 1.5 * time_step; ppVignetteSetAlpha(uniform, param1); vig = ppVignetteGetColor(uniform); vig->red += (key_t - key_y) * 5 * time_step; vig->green += (key_g - key_h) * 5 * time_step; vig->blue += (key_u - key_i) * 5 * time_step; ppVignetteSetColor(uniform, vig); draw_text(str_printf(NULL, "Custom vignette color:\nRed = %d [T]/[Y]\nGreen = %d [G]/[H]\nBlue = %d [U]/[I]", (int)vig->red, (int)vig->green, (int)vig->blue), 50, 300, COLOR_WHITE); coverage_start += 0.125 * (key_b - key_n) * time_step; ppVignetteSetStart(uniform, coverage_start); ppVignetteSetEnd(uniform, coverage_end); break; } case GRAIN: { draw_text(str_printf(NULL, "Alpha = %.2f\nScale = %.2f\nSpeed = %.2f\nBrightness = %.2f", (double) ppGrainGetAlpha(uniform), (double) ppGrainGetScale(uniform), (double) ppGrainGetSpeed(uniform), (double) ppGrainGetBrightness(uniform)), screen_size.x - 150.0, 15.0, COLOR_WHITE); param1 = ppGrainGetAlpha(uniform); param1 += (key_t - key_y) * time_step * 0.55; ppGrainSetAlpha(uniform, param1); param2 = ppGrainGetScale(uniform); param2 += (key_g - key_h) * time_step * 0.55; ppGrainSetScale(uniform, param2); param3 = ppGrainGetSpeed(uniform); param3 += (key_b - key_n) * time_step * 0.55; ppGrainSetSpeed(uniform, param3); param4 = ppGrainGetBrightness(uniform); param4 += (key_j - key_k) * time_step * 0.15; ppGrainSetBrightness(uniform, param4); break; } } } wait(1.0); } }
virtual string dotColor() const { return ((ifelse() & VU_PLI) ? "red" : (ifelseBoth() ? "blue" : (ifelseTrue() ? "green" : "darkgreen"))); }